<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>自动跳转</title>
		<style>
			body {
				text-align: center;
			}
			
			#sec {
				color: red;
				font-size: 25px;
			}
		</style>
	</head>

	<body>
		<h2>提交成功</h2>
		<a href="http://www.baidu.com">
			<span id="sec">5</span> 秒后会自动跳转，也可单机跳转
		</a>
		<script>
			/*1、数字递减
			  2、当数字到0时，跳转到某个URL*/
			var number = 5;
			var span = document.getElementById('sec')

			function a() {
				if(number > 0) {
					number--;
					span.innerHTML = number;
				} else {
					clearInterval(timer);
					location.href="http://www.baidu.com";
				}
			}
			var timer = window.setInterval(a, 1000);
		</script>
	</body>

</html>